var express = require('express');
var router = express.Router();
var data = require('./data');

/* GET users listing. */
router.get('/', function(req, res, next) {
    let acc = req.query.acc;
    let accData;
    if(data.wholeAccData[acc])
    {
      console.log("已有帐号..." + acc);
      accData = data.wholeAccData[acc];
    }
    else
    {
      //新帐号初始化
      console.log("新帐号初始化..." + acc);
      accData = new data.AccData(acc,100,[],{});
      data.wholeAccData[acc] = accData;
    }
    
  res.setHeader("Access-Control-Allow-Origin", "*");
  res.send(JSON.stringify(accData));
});

module.exports = router;
